<%@page import="nstock.Userinfo"%>
<%@page import="nstock.UserinfoDAO"%>
<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type"
			content="text/html; charset=ISO-8859-1">
		<title>Change Live</title>
	</head>
	<body>

		<%
			String inputmail = request.getParameter("inputmail");
			String PassValue = request.getParameter("PassValue");
			UserinfoDAO uid = new UserinfoDAO();
			List userlist = uid.findByMail(inputmail);
			if (userlist.size() == 1) {
                    Userinfo ufo = (Userinfo)userlist.get(0);
				if (ufo.getPass().compareToIgnoreCase(PassValue) == 0) {
					Cookie elogin = new Cookie("login", inputmail);
					elogin.setMaxAge(0);
					response.addCookie(elogin);
					Cookie eagent = new Cookie("agent", ufo.getType());
					eagent.setMaxAge(0);
					response.addCookie(eagent);
					request.getRequestDispatcher("image.jsp").forward(request,
							response);
				} else {
					request.getRequestDispatcher("error.jsp").forward(request,
							response);
				}
			} else {
				request.getRequestDispatcher("error.jsp").forward(request,
						response);
			}
		%>

	</body>
</html>